package cn.mianshiyi.example.config;

import cn.mianshiyi.braumclient.exception.RateLimitBlockException;
import cn.mianshiyi.braumclient.exception.RateLimitTimeoutBlockException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author shangqing.liu
 */
@ControllerAdvice
public class ExceptionConfig {

    /**
     * 处理自定义异常
     *
     * @param exception BusinessException类型，自定义异常
     * @return WebResult 自定义返回集合
     */
    @ExceptionHandler({RateLimitTimeoutBlockException.class, RateLimitBlockException.class})
    @ResponseBody
    public String businessException(Exception exception) {
        return exception.getMessage();
    }
}
